package com.ibeetl.cms.dao;

import com.ibeetl.admin.core.entity.CoreFunction;
import com.ibeetl.cms.entity.CmsCatalog;
import org.beetl.sql.core.annotatoin.Param;
import org.beetl.sql.core.annotatoin.Sql;
import org.beetl.sql.core.annotatoin.SqlResource;
import org.beetl.sql.core.annotatoin.SqlStatement;
import org.beetl.sql.core.engine.PageQuery;
import org.beetl.sql.core.mapper.BaseMapper;

import java.util.List;
import java.util.Map;

@SqlResource("core.coreCatalog")
public interface CmsCatalogDao extends BaseMapper<CmsCatalog> {

    public void queryByCondition(PageQuery query);

    public void clearCatalogFunction( List<Long> functionIds);

    public List<CmsCatalog> allCatalogWithURL();

    /**
     * 查询某个类型下的栏目集合
     * @param type 栏目类型
     * @return
     */
    List<CmsCatalog> findAllList(String type);
    
    /**
     * 查询字段类型列表
     * @param delFlag 删除标记
     * @return
     */
    @SqlStatement(returnType = Map.class)
    List<Map<String, String>> findTypeList(int delFlag);

  

    /**
     * 根据父节点Id查询子节点数据
     * @param id 父节点id
     * @return
     */
    List<CmsCatalog> findChildByParent(Long id);

    /**
     * 根据条件分页查询
     * @param query 查询条件
     */
    void queryByCondtion(PageQuery query);


    @Sql("select f.* from cms_catalog c , core_function f where c.ARTICLE_LIST_FUNCTION_ID = f.id and c.id = ?")
    CoreFunction getArticleListFunctionFromCatalogId(@Param(value = "catalogId") Long catalogId);

    @Sql("select * from cms_catalog c where c.code = ?")
    public CmsCatalog getCatalogByCode(@Param(value="code")String code);

}
